def sortColumns(matrix): # DO NOT modify this line 
    zhuanzhi=[[row[i] for row in matrix] for i in range(len(matrix[0]))]
    for i in zhuanzhi:
        i.sort()
    mx4=[[row[j] for row in zhuanzhi] for j in range(len(zhuanzhi[0]))]
    return mx4
def main():
    mx1 = []
    n = int(input())
    for i in range(n):
        numbers = [ eval(x) for x in input().split() ]
        mx1.append(numbers)
    mx2 = sortColumns(mx1)
    for row in mx2:
        print(" ".join(map(str,row)))
    
if __name__ == "__main__":
    main()